#include<iostream>
using namespace std;
int main()
{
	int a,b,f,i,j;
	char c;
	cin>>a>>b>>c>>f;
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			if(f==0)
			{
			  if(i==1||i==a||j==1||j==b)
			  cout<<c;
			  else
			  cout<<' ';
		    }
			else
			cout<<c; 
		}
		cout<<endl;
	
	}
	return 0;
}
